/**
 * CopyRight (C) 2017-2022 Xiamen Rongneng Technology Co., Ltd. .
 * Created by maolongxing@ipower.cn on 2018/10/24 13:45.
 */
import React, { PureComponent } from 'react';
import Button, { ButtonProps, ButtonType } from 'antd/es/button/button';
import './HYButton.less';
import ClassNames from 'classnames';

export declare type HyProps = {
  isWhite?: boolean; //白色背景按钮
};

export declare type Props = ButtonProps & HyProps;

export interface State {}

class HYButton extends PureComponent<Props, State> {
  constructor(props: Props) {
    super(props);
    this.state = {};
  }

  render(): JSX.Element {
    let { className, isWhite, type, ...btnProps } = this.props;
    let newType: ButtonType = type;
    let newClassName;
    if (isWhite) {
      newType = 'default';
      newClassName = ClassNames('hy-btn', 'hy-btn-white', className);
    } else {
      newClassName = ClassNames('hy-btn', className);
    }
    return <Button className={newClassName} type={newType} {...btnProps} />;
  }
}

export default HYButton;
